package hu.mapro.gwtui.gxt.client.ui;

import hu.mapro.gwtui.gxt.client.modelkeyprovider.DefaultModelKeyAdapter;
import hu.mapro.gwtui.gxt.client.recordseditor.requestfactory.Interface;
import hu.mapro.model.Getter;
import hu.mapro.model.Setter;
import hu.mapro.model.meta.Field;
import hu.mapro.model.meta.HasLabel;

import com.google.web.bindery.requestfactory.shared.ValueProxy;
import com.sencha.gxt.data.shared.ModelKeyProvider;

public class ValueRecordsEditor<
	T extends ValueProxy,
	F extends Field<T,?>&Getter<T, ? extends Comparable<?>>,
	//RO extends Field<T,?>&HasLabel&Getter<T, ?>,
	RW extends Field<T,?>&HasLabel&Getter<T, ?>&Setter<T, ?>
> extends ComplexRecordsEditor<T, F> {

	hu.mapro.gwtui.gxt.client.recordseditor.requestfactory.Interface<T> requestFactoryAdapter;
	
//	@Override
//	protected Interface<T> createRequestFactoryAdapter() {
//		return requestFactoryAdapter;
//	}

	@Override
	protected ModelKeyProvider<? super T> createModelKeyAdapter() {
		// TODO replace with a mechanism that does not keep a reference to everything 
		return new DefaultModelKeyAdapter<T>();
	}

	public void setRequestFactoryAdapter(
			hu.mapro.gwtui.gxt.client.recordseditor.requestfactory.Interface<T> requestFactoryAdapter) {
		this.requestFactoryAdapter = requestFactoryAdapter;
	}

	@Override
	public void build() {
		
		
		super.build();
	}
	
	@Override
	protected Interface<T> createPersistenceAdapter() {
		return requestFactoryAdapter;
	}
	
}
